package serverside;


/**
 *
 * @author AbdallaEssam
 */
public class Deposit extends Transaction{
    
    private Keypad keypad; 
    String tmp;
    public Deposit(int _cardID, DatabasePack.BankDatabase atmBankDatabase, Screen atmScreen, Keypad atmKeypad) {
        super(_cardID, atmBankDatabase, atmScreen);
        keypad = atmKeypad;
    }

    @Override
    public void execute() {
        System.out.println("Transaction::CashDeposit");
        Screen screen = getScreen();
        DatabasePack.BankDatabase database = getBankDatabase();
        
        screen.sendDataToClient("You can deposit.");
        String result = database.Deposit(getCardID(), Integer.parseInt(tmp = keypad.getInput()));       
        System.out.println("Transaction::CashDeposit client sent: " + 
                tmp);
        screen.sendDataToClient(result);
        System.out.println("Transaction::CashDeposit result: " + result +
                    "\n");
    }
    
}
